package com.plant.action;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.plant.entity.UgcUser;
import com.plant.service.HelpService;
import com.plant.service.PlantService;
import com.plant.tool.Test;


import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 			---涉及的表：表1：ugc_user；author TOMlee
 */
@Controller //注解控制器
@RequestMapping(value = "/plant")//注解请求路径
public class PlantAction {

	@Resource(name = "plantServiceImpl")//spring 注入依赖管理 注入管理接口service
    private PlantService plantService;
    
    @Resource(name = "helpServiceImpl")
    private HelpService helpService;
    
	@RequestMapping(value = "test")
    @ResponseBody      //requestBody 调用json视图解析器
    public String user() {  //1.查看所有用户的信息 返回json数据
		   List<String> alldevicetoken=new ArrayList<String>(); 
		   UgcUser u=new UgcUser();
		   u.setId(147);
		   alldevicetoken=helpService.AllUserDeviceToken(u);
		   Set<String> set=new HashSet<String>();
		   set=Test.OnlyList(alldevicetoken);
		   Iterator<String> it=set.iterator();
		   while (it.hasNext()) {
			   String divice=it.next();
			   if(divice==null||"".equals(divice)){
				   System.out.println("为空或为null"+divice+"'");
			   }
			   System.out.println(divice);
		   }
		return null;
    }

    
	
	
    
    
    
    
    
    
    
    
    
    
    
    
//    
//    @RequestMapping(value = "single")
//    public void single(PrintWriter pw) {                                       //返回string 类型的数据
//
//        pw.write("教师机读卡傻就傻");
//    }
//
//    @RequestMapping(value = "receive", method = RequestMethod.POST)
//    public void receice(@RequestBody User u) {
//        System.out.println(u.getAge() + u.getName() + u.getId());
//    }
//
//    @RequestMapping(value = "receiveList")
//    public void receiceList(@RequestBody User[] u) {
//        for (User user : u) {
//            System.out.println(user.getAge() + user.getName() + user.getId());
//        }
//    }
//
//    @RequestMapping(value = "receiveSingle", method = RequestMethod.POST)        //接受单个实体
//    public void receiceSingle(User u) {
//        System.out.println(u.getAge() + u.getName() + u.getId());
//    }
}
